local parent, ns = ...
local global = GetAddOnMetadata(parent, 'PSLib-ExtendedMacro')
local _VERSION = GetAddOnMetadata(parent, 'version')
-- add-on object
local psLib = {};

psLib.Commands = {};
SlashCmdList["PS"] = function(msg, editbox)
	local command = string.match(msg,"^[%a%d]*$") or string.match(msg,"^[%a%d]* ");
	command = strtrim(command);
	
	if(command and psLib.Commands[command]) then
		local arguments = strtrim(string.sub(msg,command:len() + 1)) or "";
		psLib.Commands[command](strsplit(";",arguments));
	end
end
_G["SLASH_PS1"] = "/ps";
_G["SLASH_PS2"] = "/PS";

psLib.AddChatCommand = function(self,chatCommand,func)
	psLib.Commands[chatCommand] = func;
end

if(global) then _G[global] = psLib end;
ns.psLib = psLib;